feat: add support for passing metadata to MCP tool calls#423
Open
Uday Shankar (udayshnk) wants to merge 1 commit intolangchain-ai:mainfrom
Open
feat: add support for passing metadata to MCP tool calls#423Uday Shankar (udayshnk) wants to merge 1 commit intolangchain-ai:mainfrom
Uday Shankar (udayshnk) wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
6cdd62f to
77ffb37
Compare
Add metaParams support to MCP tool calls and expose MCP response _meta in MCPToolArtifact. This allows callers to pass metadata parameters to MCP tools and access response metadata returned by MCP tool calls alongside structured_content. Per the MCP specification (https://modelcontextprotocol.io/specification/2025-06-18/basic/index#general-fields), _meta is defined as a separate field at the request level. This implementation correctly treats metaParams as a distinct parameter passed to session.call_tool(meta=...), following the spec's CallToolRequest structure where _meta is a sibling to 'name' and 'arguments', not nested within arguments. Metadata is passed exclusively through interceptors, keeping tool arguments clean and protocol-level metadata separate from LLM-facing parameters. Changes: - Bump mcp dependency from 1.9.2 to 1.22.0 - Add metaParams field to MCPToolCallRequest for passing metadata to MCP servers - Add metaParams parameter to tool calls passed as 'meta' to session.call_tool() - Add _meta field to MCPToolArtifact (with total=False to make both fields optional) - Update tools and interceptors to support metadata parameters - Add comprehensive tests for metadata passing and interceptor composition - Update README documentation with interceptor-based metadata examples - Ensure clean separation: tool arguments remain pure, metadata handled via interceptors
77ffb37 to
9f2e4dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add metadata support to MCP tool calls